package com.example.springbootelasticsearch.model;

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.*;

import java.util.Date;

@Data
@ToString
@NoArgsConstructor
@Setting(settingPath = "es/es_setting.json")
@Document(indexName = "sight")
public class EsSight {
	/**
	 * 主键
	 */
	@Id
	private Long sightId;
	/**
	 * 名称
	 */
	@MultiField(mainField = @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_max_word"),
			otherFields = @InnerField(suffix = "pinyin", type = FieldType.Text, analyzer = "pinyin", searchAnalyzer = "pinyin"))
	private String sightName;
	/**
	 * 价格
	 */
	@Field(type = FieldType.Double, index = false)
	private Double price;
	/**
	 * 地址
	 */
	@Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_max_word")
	private String address;
	/**
	 * 图片
	 */
	@Field(type = FieldType.Keyword, index = false)
	private String imageUrl;
	/**
	 * 精度
	 */
	@Field(type = FieldType.Double, index = false)
	private Double longitude;
	/**
	 * 维度
	 */
	@Field(type = FieldType.Double, index = false)
	private Double latitude;
	/**
	 * 定位信息
	 */
	@GeoPointField
	private String position;
	/**
	 * 距离
	 */
	@Field(type = FieldType.Keyword, index = false)
	private String distance;
	/**
	 * 创建时间
	 */
	@Field(type = FieldType.Date, format = DateFormat.date_hour_minute_second)
	private Date createTime;

}